|
Some fairly minor, but nevertheless noteworthy changes have been made to the Music Object API between versions 3.2.x and 3.3.x. Some of these changes may require that your existing sonified code be modified in some small way. To help transition your code to use the 3.3.x (and later) versions of Music Object, this document provides guidelines for easily updating your code.
|
| 1. Make Backups |
Create a backup of the local versions of any Web sites you wish to update BEFORE you make any of the following changes. This is a wise safety measure.
| 2. Download the Latest Music Object |
Download the new "music-object.js" file by right-clicking (click-and-hold for Mac users) on the link below and selecting the 'Save Link As...' or 'Save Target As...' option from the pop-up menu. Save the file to your local hard drive.
If this does not work or you do not see a 'Save Link As...' or 'Save Target As...' option in the pop-up, you can also obtain the new "music-object.js" file if you download the latest version of the Beatnik Music Object Documentation. Once you have downloaded and de-archived the documentation, you can find the "music-object.js" file by following these steps...
IMPORTANT : Be sure NOT to move the "music-object.js" file outside of the "javascript" folder, as this would cause the documentation to not function correctly.
| 3. Replace Your Existing Music Object |
Now that you have the latest "music-object.js" file, simply replace the existing "music-object.js" file you are using in any and all Web sites that you have authored with interactive Beatnik content.
| 4. Modify Your Code |
Although we've provided the backwards compatibility patch, Music Object Patch - Pre 3.3.0, we strongly advocate that you play it safe and just go through the process of updating your code as soon as you start using Music Object 3.3.x. The changes in the Music Object API may not even affect your code, depending on whether or not your code made reliance upon any of the features that have changed. Either way, the best course of action is to religiously follow the steps outlined below on each sonified Web page.
If you have a text editor that can open multiple documents at the same time and perform a search-and-replace procedure through all the currently open documents, this would be ideal. You should open up all documents that have been sonified using the Music Object API into this text editor. If, on the other hand, your text editor cannot open multiple documents, then you will have to repeat this process for each sonified document by loading in the documents one at a time and performing the search-and-replace procedures listed below.
Because the Music.platform static property has been deprecated in Music Object 3.3.x (see the Music Object 3.3.0 version history entry), it is necessary to modify all references to this property to use the new Music.clientPlatform static property. In order to do this, you should perform a search procedure to find each instance of the text "platform". For each instance that you find, make sure that the statement is referencing the Music Object API's Music.platform static property and not a custom variable named "platform" or the navigator.platform property. Once you're certain that the Music.platform property is being used in the statement, replace the reference to this property with a reference to the new Music.clientPlatform property.
So, for example, the code...
if (Music.platform == 'WebTV') {
alert ('Some features of this content may not work on this platform');
}
|
...would become...
if (Music.clientPlatform == 'WebTV') {
alert ('Some features of this content may not work on this platform');
}
|
Be careful when you search for uses of the Music.platform static property to not search specifically for the text "Music.platform", since some uses of this property may occur within "with" statements, such as the code...
with (Music) {
showCompatibilityPrompt = false;
if (platform == 'WebTV') {
alert ('Some features of this content may not work on this platform');
}
}
|
In such cases, you should not only change the reference to the deprecated Music.platform property to a reference to the new Music.clientPlatform property, but it is also advocated that you update such code to no longer use the "with" statement (see the point below Remove "with" Statements).
So, the code...
with (Music) {
showCompatibilityPrompt = false;
if (platform == 'WebTV') {
alert ('Some features of this content may not work on this platform');
}
}
|
...would then become...
Music.showCompatibilityPrompt = false; if (Music.clientplatform == 'WebTV') { alert ('Some features of this content may not work on this platform'); } |
IMPORTANT: Because the Music.platform static property has only been deprecated and has not yet become unsupported, this is a non-critical change. However, it is highly recommended that you make this change now rather than later.
Because the Music.requiredMinVersion static property has become a read-only property in Music Object 3.3.x (see the Music Object 3.3.0 version history entry), it is necessary to change all assignments of the Music.requiredMinVersion static property to become calls to the new Music.requireMinPlayerVersion static method. In order to do this, perform a search procedure to find each instance of the text "requiredMinVersion". For each instance that you find, check to see if the statement that this property is being used in is an assignment. If the statement is assigning a value to the Music.requiredMinVersion static property, then you must replace the assignment statement with a call to the Music.requireMinPlayerVersion static method.
For example, the statement...
Music.requiredMinVersion = '2.0'; |
...would become...
Music.requireMinPlayerVersion ('2.0'); |
Be careful when you search for uses of the Music.requiredMinVersion static property to not search specifically for the text "Music.requiredMinVersion", since some uses of this property may occur within "with" statements, such as the code...
with (Music) {
showCompatibilityPrompt = false;
requiredMinVersion = '2.0'
}
|
In such cases, you should not only change the assignment of the Music.requiredMinVersion static property to become a call to the Music.requireMinPlayerVersion static method, but it is also advocated that you update such code to no longer use the "with" statement (see the point below Remove "with" Statements).
So, the code...
with (Music) {
showCompatibilityPrompt = false;
requiredMinVersion = '2.0';
}
|
...would then become...
Music.showCompatibilityPrompt = false; Music.requireMinPlayerVersion ('2.0'); |
IMPORTANT: Because the Music.requiredMinVersion static property is still supported and because the Music Object API will continue to behave the same way for content that explicitly assigns a value to this property, this is a non-critical change. However, it is highly recommended that you make this change now rather than later. Code that is not updated to accommodate this API change may not work correctly later on when used with other code modules that specify their player version requirements in a cooperative manner using the new Music.requireMinPlayerVersion method.
Music Object 3.3 offers the ability to create truly hidden Music Object instances that have no graphical control panel and do not occupy any layout space (see the Music Object 3.3.0 version history entry). In order to get the benefit of this new feature, however, you need to make sure that you specify the HIDDEN embedding property and you also specify the value 0 for both the WIDTH and HEIGHT embedding properties for any Music Object instances that you want to be hidden and that you embed using the magicEmbed instance method or the Music.magicEmbed static method. Because of problems with some older browsers, earlier documentation has advocated that the value 2 always be specified for the WIDTH and HEIGHT embedding properties when embedding hidden instances. However, this is no longer so much of an issue and it is now quite safe to specify a width and height of 0 when embedding instances.
As an example, in order to embed an instance that is truly hidden and doesn't affect the layout flow of other elements on the page, the statement...
myMusicObject.magicEmbed ( 'SRC="my-file.rmf" AUTOSTART=TRUE LOOP=FALSE WIDTH=2 HEIGHT=2 HIDDEN' ); |
...would have to be changed to...
myMusicObject.magicEmbed ( 'SRC="my-file.rmf" AUTOSTART=TRUE LOOP=FALSE WIDTH=0 HEIGHT=0 HIDDEN' ); |
![]()
Music Object instances that are embedded using the stubEmbed and preloadEmbed instance methods automatically inherit this new feature, so no updating of your code that uses either of these methods may be required.
With the new mechanism for embedding truly hidden player instances, a problem was found with embedding hidden instances in table cells, that would cause intermittent crashes in some 4.x versions of Netscape Navigator. Hidden instances should, therefore, not be embedded within table cells (or any other container elements, for that matter). Hidden instances should only be embedded as top level members of the BODY tag. For more information, consult the section Authoring Issues: Embedding Hidden Instances in Table Cells.
According to the latest revision of the ECMA-262 standard (JavaScript, JScript, etc.), the "with" statement has been deprecated. While it may be supported for some browser versions in the future in order to maintain backwards compatibility with existing content, there is some question as to how consistent the implementation of the statement will be across all browsers that support ECMA-262, given that the statement will no longer be part of the official language specification. Because of this, it was decided to remove all "with" statements from all Music Object code modules (see the Music Object 3.3.0 version history entry) as well as all sample code examples included as part of the documentation (see the Music Object 3.3.0 version history entry). We strongly advise that you do the same with all sonification code. In doing so, you will reduce the risk of your code breaking unexpectedly at some stage in the future.
In order to remove "with" statements, perform a search procedure to find each instance of the text "with". For each instance that you find, determine if this text is actually part of a JavaScript "with" statement and not just part of a string literal, comment, variable, function name, etc. For each legitimate "with" statement that you find, modify the code so that each property or method that is a member of the object specified in the "with" statement is prefixed explicitly with the object's name. Then, remove the "with" statement that encapsulates the code block.
As an example, the code...
with (myMusicObject) {
Music.setReverbType (1);
setController (1,10,0);
playNote (1,0,15,63,127,1000);
}
|
...would become...
Music.setReverbType (1); myMusicObject.setController (1,10,0); myMusicObject.playNote (1,0,15,63,127,1000); |
After performing the above changes to your code, your content will then be Music Object 3.3.x compliant. Under no circumstances should you perform this procedure upon the "music-object.js" file itself - ONLY your sonified documents which source in the "music-object.js" file.
| 5. Test Your Content |
Check your Web site pages locally to ensure that all your content is still working. If possible, use several browser versions in your testing. Do not delete the backup(s) that you made in step 1 until you have uploaded the changes to the online version of your Web site and verified that all your content works online as well. There are some authoring issues that only impact content when it is being served from a Web server. Even if you have tested your content online and are confident everything is peachy, you may still wish to keep the backups hanging around for a week or so, just in case. Sometimes it is not possible to test all possibilities and you may receive reports from Web site visitors saying that things are suddenly amiss with your content. Always play it safe with your Web content.
| Music Object Patch - Pre 3.3.0 |
For your convenience, Beatnik Inc. is providing a temporary Music Object patch to ease the transition to the new 3.3.x (and higher) versions. All that is necessary is to source in the tiny additional JavaScript file immediately after sourcing in the "music-object.js" file, as follows...
<SCRIPT SRC="music-object.js"></SCRIPT> <SCRIPT SRC="music-object-p-pre320.js"></SCRIPT> |
Using this JavaScript file will smooth over the API differences between versions 3.2.x and 3.3.x, and existing code should continue to work without further modification. You can find the "music-object-p-pre320.js" file inside the "javascript" folder of this documentation. If you absolutely need to upgrade to a 3.3.x (or later) version of Music Object because of some new features you need to use in your code, but you don't have the time to immediately make the changes outlined above, then this may be an acceptable temporary solution. However, it is still recommended that you follow the guidelines above for updating your content as soon as possible.
If you are unfamiliar with Music Object extensions, consult the section About Music Object Extensions.